package com.ly.spring.jdbc.dao;

import com.ly.spring.jdbc.entity.Oprecored;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class OprecordDao {
    @Autowired
    JdbcTemplate jdbcTemplate;

    public Oprecored queryByid(int aid) {
        String sql = "select * from bank_oprecord where aid = ?";
        return jdbcTemplate.queryForObject(sql,
                new BeanPropertyRowMapper<Oprecored>(Oprecored.class),aid);
    }

    public void insert(Oprecored oprecored) {
        String sql = "insert into bank_oprecord values(default,?,?,?,now(),?)";
        jdbcTemplate.update(sql,oprecored.getAid(),
                oprecored.getOpmoney(),
                oprecored.getCharge(),
                oprecored.getRemark());

    }

}
